import { on_login } from "../../utils/api.js";
const app = getApp();
Component({
    properties: {
        loginStatus: Boolean
    },
    data: {
        canIUse: wx.canIUse('button.open-type.getUserInfo')
    }, // 私有数据，可用于模版渲染

    methods: {
        onGotUserInfo: function (e) {
            if (!app.globalData.token) {
                if (e.detail.rawData) {
                    on_login(app.globalData.code, e.detail.encryptedData, e.detail.iv).then((token) => {
                        wx.showTabBar({
                            aniamtion: true
                        })
                        app.globalData.token = token;
                        this.setData({
                            loginStatus: false
                        })
                    });
                }
            }
            this.triggerEvent('onGotUserInfo')
        },
    }

})